package org.tigr.htc.server;

/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import org.tigr.htc.cmd.ICommand;

/**
 * The <b>IRunner</b> interface that all command runners need to implement.
 * This allows all command runners to be queued, scheduled and managed.
 *
 */
public interface IRunner extends Runnable {
	
    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
     */
    public void run();
    
    /**
     * <code>stop</code> a command that has already been submitted but 
     * has not finished yet.  
     * The final state of the command will be INTERRUPTED.
     * @return currently not used
     * @throws Exception
     */
    public boolean stop() throws Exception;
    
    /**
     * <code>hold</code> a command.  If a command is running have the grid 
     * pause the job and free the resource.  If the command is waiting in the
     * queue remove it from the wait queue.
     * @return currently not used
     * @throws Exception
     */
    public boolean hold() throws Exception;
    
    /**
     * <code>release</code> a command that was previously held.
     * @return currently not used
     * @throws Exception
     */
    public boolean release() throws Exception;
    
    /**
     * <code>monitor</code> the progress on the command running on the grid
     * @return boolean true if command is in a completed state
     * 	false if command is stills needs to continue to be monitored
     */
    public boolean isRunnerComplete();
    
    /**
     * <code>getICommand</code> get the command associated with this runner.
     * @return ICommand interface to command
     */
    public ICommand getICommand();
}
